package com.oritsh.dicom.service;

import com.oritsh.dicom.utils.DataSetHelper;
import org.dcm4che.data.Attributes;
import org.dcm4che.data.Tag;

/**
 * Created with IntelliJ IDEA.
 * User: zarra
 * Date: 14-2-5
 * Time: 下午8:43
 * Copyright Shanghai Orient Rain Information Technology Co.,Ltd.
 */
public class CFindAttributesTemplateStaticImpl implements CFindAttributesTemplate {

    @Override
    public Attributes templateForFindByPatientID(String pid) {
        Attributes attributes = DataSetHelper.createDataSetForNullTags(
                new int[]{
                        Tag.PatientName,
                        Tag.PatientSex,
                        Tag.PatientBirthDate,
                        Tag.StudyInstanceUID,
                        Tag.StudyDate,
                        Tag.StudyTime,
                        Tag.StudyDescription,
                        Tag.ModalitiesInStudy
                }
        );
        DataSetHelper.putValueToDataSet(attributes, Tag.PatientID, pid);
        DataSetHelper.putValueToDataSet(attributes,Tag.QueryRetrieveLevel,"STUDY");

        return attributes;
    }

    @Override
    public Attributes templateForFindByStudyDate(String date) {
        Attributes attributes = DataSetHelper.createDataSetForNullTags(
                new int[]{
                        Tag.PatientID,
                        Tag.PatientName,
                        Tag.PatientSex,
                        Tag.PatientBirthDate,
                        Tag.StudyInstanceUID,
                        Tag.StudyTime,
                        Tag.StudyDescription,
                        Tag.ModalitiesInStudy
                }
        );
        DataSetHelper.putValueToDataSet(attributes,Tag.StudyDate,date);
        DataSetHelper.putValueToDataSet(attributes,Tag.QueryRetrieveLevel,"STUDY");

        return attributes;
    }

    @Override
    public Attributes templateForFindByStudyUID(String pid,String studyUID) {
        Attributes attributes = DataSetHelper.createDataSetForNullTags(
                new int[]{
                        Tag.PatientName,
                        Tag.PatientSex,
                        Tag.PatientBirthDate,
                        Tag.StudyInstanceUID,
                        Tag.StudyDate,
                        Tag.StudyTime,
                        Tag.StudyDescription,
                        Tag.SeriesInstanceUID,
                        Tag.SeriesDescription,
                        Tag.SeriesNumber,
                        Tag.ModalitiesInStudy
                }
        );
        DataSetHelper.putValueToDataSet(attributes, Tag.PatientID, pid);
        DataSetHelper.putValueToDataSet(attributes, Tag.StudyInstanceUID,studyUID);
        DataSetHelper.putValueToDataSet(attributes,Tag.QueryRetrieveLevel,"SERIES");
        return attributes;
    }

    @Override
    public Attributes templateForFindBySeriesUID(String studyUID,String seriesUID) {
        Attributes attributes = DataSetHelper.createDataSetForNullTags(
                new int[]{
                        Tag.PatientName,
                        Tag.PatientSex,
                        Tag.PatientBirthDate,
                        Tag.StudyInstanceUID,
                        Tag.StudyDate,
                        Tag.StudyTime,
                        Tag.StudyDescription,
                        Tag.SeriesInstanceUID,
                        Tag.SeriesDescription,
                        Tag.SeriesNumber,
                        Tag.ModalitiesInStudy,
                        Tag.SOPInstanceUID
                }
        );
        DataSetHelper.putValueToDataSet(attributes, Tag.StudyInstanceUID,studyUID);
        DataSetHelper.putValueToDataSet(attributes,Tag.SeriesInstanceUID,seriesUID);
        DataSetHelper.putValueToDataSet(attributes, Tag.QueryRetrieveLevel, "IMAGE" );
        return attributes;
    }

    @Override
    public Attributes templateForFindByImageUID(String imageUID) {
        Attributes attributes = DataSetHelper.createDataSetForNullTags(
                new int[]{
                        Tag.SOPInstanceUID
                }
        );
        DataSetHelper.putValueToDataSet(attributes,Tag.SOPInstanceUID,imageUID);
        DataSetHelper.putValueToDataSet(attributes, Tag.QueryRetrieveLevel, "IMAGE");

        return attributes;
    }
}
